package com.baox.agridata.synchronous.controller;


import com.alibaba.fastjson.JSON;
import com.baox.agridata.synchronous.service.TCCAAService;
import com.baox.agridata.synchronous.service.TCCABService;
import com.baox.agridata.synchronous.service.TCCOutAAService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/business")
@CrossOrigin
@Slf4j
public class BusinessController {

    @Autowired
    private TCCABService tccabService;


    @Autowired
    private TCCAAService tccaaService;


    @Autowired
    private TCCOutAAService tccOutAAService;


    @GetMapping("/staticsSC")
    public String staticsSC(String startTime, String endTime) {
        Map resultMap = new HashMap();
        resultMap.put("code", 100);
        resultMap.put("msg", "统计出错！");
        try {
            Integer SRCAnimalB = tccabService.selectSiChuanReceiveCDAnimalB(startTime, endTime);
            Integer STCAnimalB = tccabService.selectSiChuanToCDAnimalB(startTime, endTime);
            Integer SRCAnimalA = tccaaService.selectSiChuanReceiveCDAnimalA(startTime, endTime);
            Integer STCAnimalA = tccOutAAService.selectSiChuanToCDOutAnimalACount(startTime, endTime);
            resultMap.put("code", 200);
            resultMap.put("msg", "success！");
            resultMap.put("SRCAnimalB", SRCAnimalB);
            resultMap.put("STCAnimalB", STCAnimalB);
            resultMap.put("SRCAnimalA", SRCAnimalA);
            resultMap.put("STCAnimalA", STCAnimalA);
            return JSON.toJSONString(resultMap);
        } catch (Exception e) {
            e.printStackTrace();
            return JSON.toJSONString(resultMap);
        }
    }

}
